package com.aaa.entity;

import jdk.net.SocketFlow;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.http.HttpStatus;

@Data
public class ResultMsg {
    private Integer code; // 状态码
    private String message; // 描述信息
    private Object data; // 数据

    public ResultMsg(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResultMsg(Object data) {
        this.data = data;
    }
//有需要可自行添加

    public static ResultMsg success(Object data) {
        return new ResultMsg(HttpStatus.OK.value(),"success",data);
    }

    public static ResultMsg error(Integer code, String message) {
        return new ResultMsg(code, message, null);
    }

    public static ResultMsg error(Integer code, Object data) {
        return new ResultMsg(code, null, data);
    }

    @Override
    public String toString() {
        return "ResultMsg{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
